

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.HashMap;

import risk.analysis.KoreanAnalysisManager;
import risk.analysis.RsnfException;

public class Test {
    	
	/**
	 * @throws RsnfException
	 */
	public static void krAnsTest() throws Exception{
	    String dbms ="aster";
	    String driver = "com.asterdata.ncluster.Driver";
	    String url = "jdbc:ncluster://10.10.188.64/beehive";
	    String user = "tera01";
	    String pass = "tera01";
	    String table_name = "text_anal.USER_DIC";
	    String mis_table_name = "text_anal.USER_MIS_DIC";
	    String syn_table_name = "text_anal.USER_SYN_DIC";
	    String com_table_name = "text_anal.USER_COM_DIC";
	    String ans_table_name = "text_anal.USER_ANS_WORD";
	    String not_ans_table_name = "text_anal.USER_NOT_ANS_WORD";
	    
		KoreanAnalysisManager kam = new KoreanAnalysisManager(); 
		
		String text = "버클어셈블리 이성,천재 시트벨트 시동꺼짐 안녕하세요 이성수 하하하";

		System.out.println(text);
		
//		String text, boolean addChk, boolean wordSpace, boolean misWordChk, boolean synChk
																//중복처리, 띄어쓰기, 오타보정, 동의어
		
//		File parent = File.createTempFile("test", "");
//		parent.mkdirs();
		
        
		HashMap<String, ArrayList> krAnlRstmap = null;
		krAnlRstmap = kam.doAnalysis(text, dbms,driver,url,user,pass,table_name,mis_table_name,syn_table_name,com_table_name,ans_table_name,not_ans_table_name,true, 0, true, true);  //중복처리, 띄어쓰기, 오타보정, 동의어
		
		ArrayList<String> widList = krAnlRstmap.get("0");
		System.out.println("======= 형태소 분석 성공 목록  ==========");
		for(String wid:widList){
		    String[] wrdps = wid.split(",");
			System.out.println(" " + wid + "\t\t word : "+wrdps[0]+"\t position : "+wrdps[1]);
		}
		ArrayList<String> wndList = krAnlRstmap.get("1");
		System.out.println("======= 형태소 분석 실패 목록  ==========");
		for(String wnd :wndList){
			System.out.println(wnd);
		}
	}
	 
	
	public static void main(String[] args) throws Exception {
		Test.krAnsTest();
	}
}
